const gulp = require("gulp");
const webpack = require("webpack-stream");
const less = require("gulp-less");

gulp.task('webpack', () => {
    const config = {
        allowEmpty: true
    };
    return gulp.src('main.js', config)
        .pipe(webpack(require('./webpack.config.js')))
        .pipe(gulp.dest('../www/js'));
});

gulp.task('less', () => {
    return gulp.src('./less/*.less')
        .pipe(less())
        .pipe(gulp.dest('../www/css'));
});

gulp.task('default', gulp.parallel('webpack', 'less'));

gulp.task('watch', () => {
    gulp.watch('less/**/*.less', gulp.series('less'));
    gulp.watch('js/**/*.js', gulp.series('webpack'));
});
